package com.zhuangxiaoyan.spring.srcode.tomcat;

import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

/**
 * @Classname Tomcat_Test
 * @Description TODO
 * @Date 2022/5/13 21:53
 * @Created by xjl
 */
public class Tomcat_Test {
    public static void main(String[] args) throws LifecycleException {
        //--------启动tomcat--------
        Tomcat tomcat=new Tomcat();
        tomcat.setPort(9090);
        tomcat.start();

        IndexServlet servlet=new IndexServlet();
        //----------重要-----------
        Context context = tomcat.addWebapp("/boot", "D:\\gitee\\");

        tomcat.addServlet("/boot","index",servlet);

        context.addServletMappingDecoded("/index.do","index");

        tomcat.getServer().await();
    }
}